package com.booksystem.campuslibrarymanagementsystem.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.booksystem.campuslibrarymanagementsystem.commen.request.userquest.Personalrequest.Favorites;
import com.booksystem.campuslibrarymanagementsystem.commen.request.userquest.Personalrequest.Favoritesdvsd;
import com.booksystem.campuslibrarymanagementsystem.entity.BooksTable;
import com.booksystem.campuslibrarymanagementsystem.entity.FavoritesTable;
import com.booksystem.campuslibrarymanagementsystem.entity.FeedbacksTable;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface FavoritesTableMapper extends BaseMapper<FavoritesTable> {
    //添加收藏
    @Insert("INSERT INTO favorites_table (account,bookid, title, author, category)\n" +
            "VALUES (#{account}, #{bookid}, #{title}, #{author},#{category})")
    int saved(Favoritesdvsd ff);
    //判断是否重复收藏
    @Select("select * From favorites_table where account = #{account} and bookid = #{bookid}")
    FavoritesTable existsByAccountAndBookid(String account,int bookid);

    //动态查询（学号，名字，身份，状态）
    List<FavoritesTable> selectfavoritesList(String title, String author, String category);

    //该账户查询所有收藏列表
    @Select("select * from favorites_table where account = #{account}")
    List<FavoritesTable> selectByaccount(@Param("account") String account);
    //删除该账户的收藏记录
    @Delete("DELETE FROM favorites_table WHERE account = #{account} AND favoriteid = #{favoriteid}")
    int deleteByAccountAndBookid(@Param("account") String account, @Param("favoriteid") int favoriteid);




}
